* This file replicates every monadic model reported in the paper and in
* the empircal appendix

* use "CPS Replication Data - Monadic Analysis Cleaned.dta", clear


xtset state_pta year

************************************
* REPORTED MODELS
*

* Subsection 1
* M1
xtreg e_log is4 polconiii st1_gdp st1_income war ally polity cpi_shock X_ptashare gattwto if eu==0 , cl(state_pta) fe i(state_pta)
margins, at(is4 = 0)
margins, at(is4 = 1)
estimates store m1
* M2
xtreg e_log is4 polconiii st1_gdp st1_income war ally polity cpi_shock X_ptashare gattwto if eu==0 , cl(st1) fe i(st1)
margins, at(is4 = 0)
margins, at(is4 = 1)
estimates store m2
* M3
xtreg e_log is4 polconiii st1_gdp st1_income war ally polity cpi_shock X_ptashare gattwto prepta_M RIG_3b depth_index if eu==0 , cl(st1) fe i(st1)
margins, at(is4 = 0)
margins, at(is4 = 1)
estimates store m3
esttab m1 m2 m3  using table1.tex, r2 obslast starlevels( * .05 ** .01) cells(b(star fmt(%9.3f)) se(par fmt(%9.3f))) replace


* Subsection 2
* M4
xtreg e_log more_cons2 polconiii st1_gdp st1_income war ally polity cpi_shock X_ptashare gattwto if eu==0 , cl(state_pta) fe i(state_pta)
estimates store m4
* M5
xtreg e_log more_lib polconiii st1_gdp st1_income war ally polity cpi_shock X_ptashare gattwto if eu==0 , cl(state_pta) fe i(state_pta)
estimates store m5
* M6
xtreg e_log is4 turnover polconiii st1_gdp st1_income war ally polity cpi_shock X_ptashare gattwto if eu==0 , cl(state_pta) fe i(state_pta)
estimates store m6
* M7
xtreg e_log more_lib turnover polconiii st1_gdp st1_income war ally polity cpi_shock X_ptashare gattwto if eu==0 , cl(state_pta) fe i(state_pta)
estimates store m7
* M8
xtreg e_log is4 electionyear polconiii st1_gdp st1_income war ally polity cpi_shock X_ptashare gattwto if eu==0 , cl(state_pta) fe i(state_pta)
estimates store m8
* M9
xtreg e_log more_lib electionyear polconiii st1_gdp st1_income war ally polity cpi_shock X_ptashare gattwto if eu==0 , cl(state_pta) fe i(state_pta)
estimates store m9
* M10
xtreg e_log ideos polconiii st1_gdp st1_income war ally polity cpi_shock X_ptashare gattwto if eu==0 , cl(state_pta) fe i(state_pta)
estimates store m10
esttab m4 m5 m6 m7 m8 m9 m10 using table2.tex, r2 obslast starlevels( * .05 ** .01) cells(b(star fmt(%9.3f)) se(par fmt(%9.3f))) replace


* Subsection 3
* M11
xtreg e_log i.is4##c.RIG_3b polconiii st1_gdp st1_income war ally polity cpi_shock X_ptashare prepta_e depth_index gattwto if eu==0 , cl(st1) fe i(st1)
estimates store m11
* M12
xtreg e_log i.more_lib##c.RIG_3b polconiii st1_gdp st1_income war ally polity cpi_shock X_ptashare prepta_e depth_index gattwto if eu==0 , cl(st1) fe i(st1)
estimates store m12
* M13
xtreg e_log i.is4##c.depth_index polconiii st1_gdp st1_income war ally polity cpi_shock X_ptashare prepta_e RIG_3b gattwto if eu==0 , cl(st1) fe i(st1)
estimates store m13
* M14
xtreg e_log i.more_lib##c.depth_index polconiii st1_gdp st1_income war ally polity cpi_shock X_ptashare prepta_e RIG_3b gattwto if eu==0 , cl(st1) fe i(st1)
estimates store m14
esttab m11 m12 m13 m14 using table3.tex, r2 obslast starlevels(* .05 ** .01) cells(b(star fmt(%9.3f)) se(par fmt(%9.3f))) replace


* APPENDIX

* A1
xtreg e_log i.is4##c.ptaage polconiii st1_gdp st1_income war ally polity cpi_shock X_ptashare gattwto if eu==0 , cl(st1) fe i(st1)
estimates store a1
* A2
xtreg e_log i.more_lib##c.ptaage polconiii st1_gdp st1_income war ally polity cpi_shock X_ptashare gattwto if eu==0 , cl(st1) fe i(st1)
estimates store a2
* A3
xtreg e_log proportion polconiii st1_gdp st1_income war ally polity cpi_shock X_ptashare gattwto if eu==0 , cl(state_pta) fe i(state_pta)
estimates store a3
* A4
xtreg e_log proportion_left polconiii st1_gdp st1_income war ally polity cpi_shock X_ptashare gattwto if eu==0 , cl(state_pta) fe i(state_pta)
estimates store a4
estout a1 a2 a3 a4 using append1.tex, starlevels(* .05 ** .01) cells(b(star fmt(%9.3f)) se(par fmt(%9.3f))) stats(N ll bic, fmt( %9.0f %9.2f) labels(N))  style(tex) replace 


* A5
xtreg e_log i.is4##i.prez polconiii st1_gdp st1_income war ally polity cpi_shock X_ptashare gattwto if eu==0 , cl(state_pta) fe i(state_pta)
estimates store a5
* A6
xtreg e_log i.more_lib##i.prez polconiii st1_gdp st1_income war ally polity cpi_shock X_ptashare gattwto if eu==0 , cl(state_pta) fe i(state_pta)
estimates store a6
* A7
xtreg e_log i.is4##c.polconiii st1_gdp st1_income war ally polity cpi_shock X_ptashare gattwto if eu==0 , cl(state_pta) fe i(state_pta)
estimates store a7
* A8
xtreg e_log i.more_lib##c.polconiii st1_gdp st1_income war ally polity cpi_shock X_ptashare gattwto if eu==0 , cl(state_pta) fe i(state_pta)
estimates store a8
estout a5 a6 a7 a8 using append2.tex, starlevels(* .05 ** .01) cells(b(star fmt(%9.3f)) se(par fmt(%9.3f))) stats(N ll bic, fmt( %9.0f %9.2f) labels(N))  style(tex) replace 


* A9
xtreg e_log is4 polconiii st1_gdp st1_income war ally polity cpi_shock X_ptashare gattwto if eu==0 & polity >= 6, cl(state_pta) fe i(state_pta)
estimates store a9
* A10
xtreg e_log more_lib polconiii st1_gdp st1_income war ally polity cpi_shock X_ptashare gattwto if eu==0 & polity >= 6, cl(state_pta) fe i(state_pta)
estimates store a10
* A11
xtreg e_log is4 polconiii st1_gdp st1_income war ally polity cpi_shock X_ptashare gattwto if eu==0 & polity <6 , cl(state_pta) fe i(state_pta)
estimates store a11
* A12
xtreg e_log more_lib polconiii st1_gdp st1_income war ally polity cpi_shock X_ptashare gattwto if eu==0 & polity <6, cl(state_pta) fe i(state_pta)
estimates store a12
estout a9 a10 a11 a12 using append3.tex, starlevels(* .05 ** .01) cells(b(star fmt(%9.3f)) se(par fmt(%9.3f))) stats(N ll bic, fmt( %9.0f %9.2f) labels(N))  style(tex) replace 


* A13
xtreg e_log is4 polconiii st1_gdp st1_income war ally polity cpi_shock X_ptashare gattwto polity_ch5yr if eu==0 , cl(state_pta) fe i(state_pta)
estimates store a13
* A14
xtreg e_log more_lib polconiii st1_gdp st1_income war ally polity cpi_shock X_ptashare gattwto polity_ch5yr if eu==0 , cl(state_pta) fe i(state_pta)
estimates store a14
* A15
xtreg e_log is4 polconiii st1_gdp st1_income war ally polity cpi_shock X_ptashare gattwto polity_ch10yr if eu==0 , cl(state_pta) fe i(state_pta)
estimates store a15
* A16
xtreg e_log more_lib polconiii st1_gdp st1_income war ally polity cpi_shock X_ptashare gattwto polity_ch10yr if eu==0 , cl(state_pta) fe i(state_pta)
estimates store a16
estout a13 a14 a15 a16 using append4.tex, starlevels(* .05 ** .01) cells(b(star fmt(%9.3f)) se(par fmt(%9.3f))) stats(N ll bic, fmt( %9.0f %9.2f) labels(N))  style(tex) replace 


* A17
heckman e_log is4 polconiii st1_gdp st1_income war ally polity cpi_shock X_ptashare gattwto if eu==0, cluster(state_pta) select(turnover = deadleader electiony finittrm yrcurnt)
estimates store a17
* A18
heckman e_log more_lib polconiii st1_gdp st1_income war ally polity cpi_shock X_ptashare gattwto if eu==0, cluster(state_pta) select(turnover = deadleader electiony finittrm yrcurnt)
estimates store a18
estout a17 a18 using append5.tex, starlevels(* .05 ** .01) cells(b(star fmt(%9.3f)) se(par fmt(%9.3f))) stats(N ll bic, fmt( %9.0f %9.2f) labels(N))  style(tex) replace 


* A19
xtreg lnimp more_lib polconiii st1_gdp st1_income war ally polity cpi_shock X_ptashare gattwto if eu==0 , cl(state_pta) fe i(state_pta)
estimates store a19
* A20 
xtreg lnimp more_lib polconiii st1_gdp st1_income war ally polity cpi_shock X_ptashare gattwto prepta_M RIG_3b depth_index if eu==0 , cl(st1) fe i(st1)
estimates store a20
estout a19 a20 using append6.tex, starlevels(* .05 ** .01) cells(b(star fmt(%9.3f)) se(par fmt(%9.3f))) stats(N ll bic, fmt( %9.0f %9.2f) labels(N))  style(tex) replace 


* A21
xtreg lnimp more_lib turnover polconiii st1_gdp st1_income war ally polity cpi_shock X_ptashare gattwto if eu==0 , cl(state_pta) fe i(state_pta)
estimates store a21
* A22
xtreg lnimp more_lib electionyear polconiii st1_gdp st1_income war ally polity cpi_shock X_ptashare gattwto if eu==0 , cl(state_pta) fe i(state_pta)
estimates store a22
* A23
xtreg lnimp ideos    polconiii st1_gdp st1_income war ally polity cpi_shock X_ptashare gattwto if eu==0 , cl(state_pta) fe i(state_pta)
estimates store a23
estout a21 a22 a23 using append7.tex, starlevels(* .05 ** .01) cells(b(star fmt(%9.3f)) se(par fmt(%9.3f))) stats(N ll bic, fmt( %9.0f %9.2f) labels(N))  style(tex) replace 


* A24
xtreg lnimp i.more_lib##c.RIG_3b turnover polconiii st1_gdp st1_income war ally polity cpi_shock X_ptashare prepta_M depth_index gattwto if eu==0 , cl(st1) fe i(st1)
estimates store a24
* A25
xtreg lnimp i.more_lib##c.depth_i turnover polconiii st1_gdp st1_income war ally polity cpi_shock X_ptashare prepta_M RIG_3b gattwto if eu==0 , cl(st1) fe i(st1)
estimates store a25
estout a24 a25 using append8.tex, starlevels(* .05 ** .01) cells(b(star fmt(%9.3f)) se(par fmt(%9.3f))) stats(N ll bic, fmt( %9.0f %9.2f) labels(N))  style(tex) replace 


* A26
xtreg lnimp i.more_lib##c.ptaage polconiii st1_gdp st1_income war ally polity cpi_shock X_ptashare gattwto if eu==0 , cl(st1) fe i(st1)
estimates store a26
* A27
xtreg lnimp i.more_lib##i.prez  polconiii st1_gdp st1_income war ally polity cpi_shock X_ptashare gattwto if eu==0 , cl(state_pta) fe i(state_pta)
estimates store a27
* A28
xtreg lnimp i.more_lib##c.polconiii st1_gdp st1_income war ally polity cpi_shock X_ptashare gattwto if eu==0 , cl(state_pta) fe i(state_pta)
estimates store a28
estout a26 a27 a28 using append9.tex, starlevels(* .05 ** .01) cells(b(star fmt(%9.3f)) se(par fmt(%9.3f))) stats(N ll bic, fmt( %9.0f %9.2f) labels(N))  style(tex) replace 


* A29
xtreg lnimp more_lib polconiii st1_gdp st1_income war ally polity cpi_shock X_ptashare gattwto if eu==0 & polity >= 6, cl(state_pta) fe i(state_pta)
estimates store a29
* A30
xtreg lnimp more_lib polconiii st1_gdp st1_income war ally polity cpi_shock X_ptashare gattwto if eu==0 & polity <6, cl(state_pta) fe i(state_pta)
estimates store a30
* A31
xtreg lnimp more_lib polconiii st1_gdp st1_income war ally polity cpi_shock X_ptashare gattwto polity_ch5yr if eu==0 , cl(state_pta) fe i(state_pta)
estimates store a31
* A32
xtreg lnimp more_lib polconiii st1_gdp st1_income war ally polity cpi_shock X_ptashare gattwto polity_ch10yr if eu==0 , cl(state_pta) fe i(state_pta)
estimates store a32
estout a29 a30 a31 a32 using append10.tex, starlevels(* .05 ** .01) cells(b(star fmt(%9.3f)) se(par fmt(%9.3f))) stats(N ll bic, fmt( %9.0f %9.2f) labels(N))  style(tex) replace 
